Release 10.1A: OpenEdge Development:
ProDataSets
Static ProDataSet and its Data-Relations
As with other Progress objects, there is a
DEFINEstatement for a static ProDataSet, which allows you to name the ProDataSet, identify the temp-table buffers it incorporates, and define the Data-Relations between those buffers in a single statement. The Data-Relation is not defined as a separate object because the relations have no significance outside the scope of a particular ProDataSet.This is the static
DEFINEDATASETstatement:
Where:
dataset-nameis a standard Progress object name.buffer-nameis a static buffer name for a previously defined temp-table whose scope includes the procedure where the ProDataSet definition is.data-rel-nameis the optional name given to the Data-Relation, which can be used to obtain its handle at run time. The default name is Relationn(withnstarting at 1 for each ProDataSet). The presence of this option requires the following keywordFOR.- The syntax for a
data-rel-specis:
parent-buffer-nameandchild-buffer-nameare memberbuffer-namesfrom theFORphrase of the definition, identifying the parent and child of a relation.field-mapping-phraseis:
The first field of each pair of
RELATION-FIELDSis from the parent buffer, the second field is from the child.In some cases, there might be a relation between two buffers that cannot be defined in terms of an equality match between fields. This might be if the relation is based on a concatenation of fields or some other expression, or if special application logic is required to identify the related records. In this case the
field-mapping-phrasecan be omitted, and it is then the responsibility of the developer to define a query on the child buffer’s Data-Source that identifies the correct records, or to supply custom logic in response to theFILLevents to take over complete responsibility for filling that level of the ProDataSet. TheREPOSITIONkeyword is discussed in the "Using the REPOSITION Data-Relation" section.Because a ProDataSet is made up of Progress temp-tables, you must define those temp-tables before you reference them in the ProDataSet.
For the example window, there are three temp-table definitions. To make it easier to use those definitions in more than one procedure, the definitions are in the include file
dsOrderTT.i:
The first temp-table,
ttOrder, is based on theOrderdatabase table but adds three fields to it:
- The first additional field is a calculated field that shows the total of all
OrderLinesfor theOrder. You’ll write event logic later on to calculate this field for each selectedOrder.- The second field is the
Customer Namefrom theCustomertable. You’ll define the join for this table in the query for thettOrdertable’s Data-Source.- The third field is the
Sales Repname from theSalesReptable. You will also join this table into your Data-Source.The second temp-table,
Design tip: When you design your ProDataSets, define temp-tables that reflect the proper internal representation of the data, regardless of what the external structure of your database might be. This way you can write your business logic and data display logic to reference properly normalized and properly organized data, in the form best suited to the data and the application. You can use ProDataSet mapping features and your own custom logic to map that internal representation to your existing database design. If your database design requires change or cleanup at a later date, you can simply change the mapping code so that the internal representation stays the same. You can also use a temp-table as a target for complex data calculations far removed from specific fields in your database, and also for data that is derived from a data source other than your database, and keep the internal form the same.ttOline, is exactly like theOrderLinedatabase table. The third temp-table,ttItem, uses a subset of the fields in theItemdatabase table.Once you have defined the temp-tables your ProDataSet needs, you define the ProDataSet itself. In this case, the ProDataSet definition is also in an include file,
dsOrder.i:
Design tip: To have a consistent definition of a static ProDataSet that you only need to maintain in one place, keep your ProDataSet definitions in include files that you include where the ProDataSet is referenced. Generally, keep your temp-table definitions in separate include files so that you can maintain them separately, and so that you can include one without the other when this is needed (for example when you need to define the temp-tables separately in the AppBuilder’s temp-table utility).
Each Data-Relation defines an implicit query for the
FILLoperation. When you attach a Data-Source tottOlineat run time that uses theOrderLinetable in the database, then the predicate for this implicit query is:
This way the ProDataSet automatically loads all
OrderLinesfor the current record in the parent temp-tablettOrder.Likewise, the Data-Relation from
ttOlinetottItemselects theItemfor each record inttOlineas thettOlinetable is filled. This results in the ProDataSet containing allItemsfor theOrderLinesthat are part of the specified top-levelOrders. Later, you’ll modify the ProDataSet so that it also loads all Items into thettItemtable. The initial definition provides the flexibility to load various combinations of data into the ProDataSet at runtime by changing or deactivating relations.
|
Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |